﻿Public Class frmDarBaja
    Dim baja As New clsBaja
    Dim Bitacora As New clsActividad
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub frmDarBaja_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ToolStrip2.Cursor = Cursors.Hand
        ToolStrip2.RenderMode = System.Windows.Forms.ToolStripRenderMode.System
        ToolStrip2.Stretch = True

        Me.datFecha.Value = Now()
        Me.txtBaja.Clear()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub toolSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub toolGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ToolStripButton4_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton4.Click
        baja.IdBaja = (BuscarIntDatoCitra("SELECT MAX(IdBaja) as IdBaja FROM Bajas")) + 1
        baja.idempleado = EmpleadoID
        baja.FechaBaja = Me.datFecha.Value
        baja.CausaBaja = Me.txtBaja.Text.Trim
        baja.Capturo = UsuarioActivo
        baja.Reportado = "No"
        baja.Finiquito = ""
        baja.Insertar()

        'Registra actividad
        Bitacora.RegistraActividad("Dió de baja a " & frmModuloEmpleadosDetalle.txtPaterno.Text.Trim & " " & frmModuloEmpleadosDetalle.txtMaterno.Text.Trim & " " & frmModuloEmpleadosDetalle.txtNombre.Text.Trim)

        Dim empleados As New clsEmpleados
        empleados.IDEmpleado = EmpleadoID
        empleados.EstadoEmpleado = "B"
        empleados.FechaBaja = datFecha.Value
        empleados.CausaBaja = txtBaja.Text
        empleados.ActualizarBaja()


        MsgBox("El empleado ha sido dado de baja correctamente", MsgBoxStyle.Information, "Aviso")
        frmModuloEmpleadosDetalle.Close()
        Me.Close()
    End Sub

    Private Sub ToolStripButton1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton1.Click
        Close()

    End Sub
End Class